﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using MVC_Project.Model;
using MVC_Project.Bll.Goods;
using MVC_Project.Api.Models.ManageGoods;
using System.Net.Http.Headers;

namespace MVC_Project.Api.Areas.Goods
{
    public class SpecController : ApiController
    {
        GoodSpecKeyBll bll = new GoodSpecKeyBll();
        // GET: api/Spec
        public List<Specs> Get()
        {
            var specs = bll.Query();

            var data = from sp in specs
                       select new Specs
                       {
                           id = sp.id,
                           name = sp.name,
                           SpecValue = from v in sp.GoodSpecValue
                                       select new SpecValue
                                       {
                                           id = v.id,
                                           value = v.value,
                                           code =v.code
                                       }
                       };


            return data.ToList();
        }

        // GET: api/Spec/5
        public string Get(int id)
        {
            return "value";
        }

        // POST: api/Spec
        public void Post([FromBody]string value)
        {
        }

        // PUT: api/Spec/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE: api/Spec/5
        public void Delete(int id)
        {
        }
    }
}
